package net.zjitc.servlet.User;

import net.zjitc.dao.UserDao;
import net.zjitc.dao.impl.UserDaoImpl;
import net.zjitc.domain.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name="UserDetailServlet",urlPatterns = "/userdetail")
public class UserDetailServlet extends HttpServlet {
    UserDao userDao=new UserDaoImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userId = req.getParameter("id");
        User user= userDao.findById(userId);
        req.setAttribute("user",user);
        req.getRequestDispatcher("/userdetail.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
